package simulator.entities;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Label;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp;
import java.io.IOException;
import java.io.InputStream;

import javax.imageio.ImageIO;

import simulator.drawengine.DrawEngine;
import simulator.enums.EntityType;
import simulator.types.Lane;

public class Car extends BaseVehicle
{
//	private BufferedImage imgCar;
	public Car(TrafficLane spawn, TrafficLane dest)
	{
		super(spawn, dest);

		_maxSpeed = 22; // 10 units/sec
		_vehicleAcceleration = 9;
		_brakePower = 16;
		_vehicleLength = 2;
		
//		ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
//		InputStream input = classLoader.getResourceAsStream("auto.png");
//		try
//		{
//			imgCar = ImageIO.read(input);
//		} catch (IOException e)
//		{
//			e.printStackTrace();
//			System.exit(0);
//		}
	}

	@Override
	public EntityType getType()
	{
		return EntityType.CAR;
	}

	@Override
	public void draw(Graphics g)
	{
		// TODO Auto-generated method stub

		// _position positie van voertuig
		// _heading richting van voertuig (radian)
		
//		double deg = Math.toDegrees(_heading);
//		
//		AffineTransform tx = new AffineTransform();
//		tx.rotate(_heading, imgCar.getWidth() / 2, imgCar.getHeight() / 2);
//
//		AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_BILINEAR);
//		imgCar = op.filter(imgCar, null);
		
		int gfxX = DrawEngine.getGraphicsX(_position.x);
		int gfxY = DrawEngine.getGraphicsY(_position.y);
		
		g.setColor(Color.yellow);
		g.fillRect(gfxX - 7, gfxY - 7, 15, 15);
//		g.fillRect(gfxX - 7, gfxY - 7, 10, 20);
//		g.fillOval(gfxX - 7, gfxY - 7, 15, 15);
//		g.drawImage(imgCar, gfxX, gfxY, null);
		
		//System.out.println("HEADING: " + _heading);
	}
}